package com.javaspeak.designpatterns.go4.structural.composite;

import java.util.List;

/**
 * Used to define the structure of composite and simple elements.
 * <p>
 * AbstractHtmlElement provides an implementation for getHtmlElements() but
 * leaves getHtml() to be implemented by parent classes.  Both TextElement and
 * HtmlElement extend AbstractHtmlElement and provide an implementation for
 * getHtml() method.  HtmlElement is a composite element which can itself be
 * comprised of composite elements while TextElement is simple.  TextElement is
 * simple as it does not make use of getHtmlElements() in its getHtml() method.
 *
 * @author John Dickerson
 */
public interface HtmlElement {

    /**
     * Returns a list of HtmlElement. The calling code can call this method and
     * a HtmlElement to the end of the list
     *
     * @return List of HtmlElement
     */
    public List<HtmlElement> getHtmlElements();

    /**
     * Returns the Html.  If the HtmlElement is a simple element it will not
     * be using the List<HtmlElement>, however if it is a composite element it
     * will iterate through the child HtmlElements and call getHtml() on each
     * of them while building up the html to return.
     *
     * @return Html
     */
    public String getHtml();
}
